<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
   <form id="emp_edit">
    <table  class="table table-bordered text-center" style="table-layout:fixed "  id="tb_edit">
		<tr>
			<th >部门名称</th>
			<th class="text-center">姓名</th>
			<th class="text-center" >职位</th>
			<th class="text-center" >手机</th>
			<th class="text-center" >固定电话</th>
			<th class="text-center" >内线</th>
			<th class="text-center" >短号</th>
			<th class="text-center" >邮箱</th>
			<th class="text-center" >排序</th>
			<th class="text-center" >编辑</th>
		</tr>
		<c:forEach items = "${emploeelist}" var = "emploee"  >
		<tr id= "${emploee.id}">
		    <td >${emploee.dept.deptName}</td>
		    <td >${emploee.name}</td>
		    <td >${emploee.position}</td>
		    <td >${emploee.mobile}</td>
		    <td >${emploee.phone}</td>
		    <td >${emploee.interphone}</td>
		    <td >${emploee.shortphone}</td>
		    <td >${emploee.email}</td>
		    <td >${emploee.ord}</td>
		    <td ><input type="button" class="btn btn-primary" value="修改"  onclick="edit(this)"/></td>
		</tr>
		
		</c:forEach>
	</table> 
	</form>
    
    <div class="container" id="111">
    <table  id="tb_save" >
      <tr>
        <td></td>
      </tr>
      <tr>
        <td>部门名称</td><td><input type="text" class="form-control" placeholder="" name="deptName" /></td>
      </tr>
      <tr>
        <td>姓名</td><td><input type="text" class="form-control" placeholder="输入姓名" id="name" /></td>
      </tr>
      <tr>
        <td>邮箱</td><td><input type="text" class="form-control" placeholder="输入邮箱" id="emal" /></td>
      </tr>
    </table>
    </div>
    
    <!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
  Launch demo modal
</button>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>
    
    
    


<script type="text/javascript">  -->
  function edit(btn){
    var tr =$(btn).parent("td").parent("tr");
	var td_list=$(btn).parent("td").siblings("td");
    var id =tr.attr("id")
    var btn_count =$("input[type='button'][value='保存']").size();
    //iframe层-父子操作
    
    
  
 function save(btn){
     
     
     var tr =$(btn).parent("td").parent("tr");
     var td_list=tr.find("input")
     var id =tr.attr("id");
     var dept=$("#edit_dept").serialize();
     $.post("updatedept",
     dept, 
     function(data){
     if(data=="success"){
         tr.html("<td class='text-left'>"+td_list.eq(1).val()+"</td><td>"+td_list.eq(2).val()+"</td><td><input type='button' class='btn btn-primary' value='修改'  onclick='edit(this)'/></td>")      
         
         $("#show_result").text("修改成功") ;
         }
         else{
         location.reload();
        }
         
        
       /* $("#td_show").show().val(data);*/
     	/* console.log(data);
        alert(data); */                                //t弹窗提示成功或失败
        })
     
 }

 
 
</script>

